#include <bits/stdc++.h>
using namespace std;

int a[100];
int binarysearch(int start, int end, int key)
{
    int low = start, high = end;
    while (low <= high)
    {
        int mid = (low + high) / 2;
        if (a[mid] < key)
        {
            low = mid + 1;
        }
        else if(a[mid]>=key)
        {
            high = mid - 1;
        }
    }
    return high;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    int t;
    cin >> t;
    while (t--)
    {
        int key;
        cin >> key;
        cout << binarysearch(1, n, key) << endl;
    }
    return 0;
}
